package com.s63.controller;

import com.s63.entity.AjaxResult;
import com.s63.modules.login.LoginService;
import com.s63.modules.login.LoginVO;
import com.s63.modules.token.Token;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "登录控制器")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "普通用户登录", notes = "使用用户名、密码登录")
   /* @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "password", value = "密码", required = true, dataTypeClass = String.class)
    })*/
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", response = AjaxResult.class),
            @ApiResponse(code = 401, message = "失败", response = AjaxResult.class)
    })
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginVO loginVO) {
        Token token = loginService.login(loginVO);
        return AjaxResult.ok(token);
    }
}
